﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ChoViet.CMS.ViewModels;
using ChoViet.Model;

namespace ChoViet.CMS.Controllers
{
    public class ForYouController : BaseController
    {
        ChoVietDataContext eDataContext = new ChoVietDataContext();
        public ActionResult Index(string emailAdress)
        {
            ForYouViewModel model = new ForYouViewModel();
            var isUser = Request["MemberEmail"] != null ? Request["MemberEmail"] : string.Empty;
            if (!string.IsNullOrEmpty(isUser))
            {
                model.User = eDataContext.Users.FirstOrDefault(e => e.Email == isUser);
            }
            else
            {
                model.EmailSystem = eDataContext.EmailSystems.FirstOrDefault(e => e.Email == emailAdress);
            }
            return View(model);
        }
    }
}
